#include <iostream>

#include <memory>
#include "TcpServer.hpp"
#include "Command.hpp"




void Usage(const std::string& tip)
{
    std::cout << "Please Use:\n\t" << tip << " local_port\n" << std::endl;
}

int main(int argc,char* argv[])
{
    if(argc !=2)
    {
        Usage(argv[0]);
        exit(USAGE_ERROR);
    }
    
    EnableScreen();

 
    uint16_t port = std::stoi(argv[1]);
    Command cmd("./safe.txt");

    func_t cmdexe = std::bind(&Command::Execute,&cmd,std::placeholders::_1);

    std::unique_ptr<TcpServer> usvr = std::make_unique<TcpServer>(port,cmdexe);
    usvr->InitServer();
    usvr->Loop();
}